Learn R Programming

NHMSAR (version 1.19)

init.theta.MSAR (NH-MSAR): Initialisation function for MSAR model fitting

Description

Initialization before fitting (non) homogeneous Markov switching autoregressive models by EM algorithm. Non homogeneity may be introduce at the intercept level or in the probability transitions. The link functions are defined here.

Usage

init.theta.MSAR(data, ..., M, order, regime_names = NULL, nh.emissions = NULL, 
nh.transitions = NULL, label = NULL, ncov.emis = 0, ncov.trans = 0,cl.init="mean")

Arguments

data

array of univariate or multivariate series with dimension T*N.samples*d with T: number of time steps of each sample, N.samples: number of realisations of the same stationary process, d: dimension

M

number of regimes

order

order of AR processes

label

"HH" (default) for homogeneous MS AR model \ "HN" for non homogeneous emissions \ "NH" for non homogeneous transitions \ "NN" for non homogeneous emissions and non homogeneous transitions

regime_names

(optional) regime's names may be chosen

nh.emissions

link function for non homogeneous emissions. If nh.emissions="linear" (default) linear link is used. If you define an other function it should follow the sample nh.emissions <- function(covar,par.emis) with par.emis of dimension M by ncov.emis+1.

nh.transitions

link function for non homogeneous transitions. If nh.transitions="gauss" (default) gaussian link is used. If M=2, "logistic" may be chosen. If you define an other function it should follow the sample nh.transitions <- function(covar,par.trans,transma) with par.emis of dimension M by ncov.trans+1.

ncov.emis

number of covariates in HN model

ncov.trans

number of covariates in NH model

cl.init

allows to choose the initialization method.

Value

return a list of class MSAR including

theta

parameter

..$transmat

transition matrix

..$prior

prior probabilities

..$A

list including the autoregressive coefficients (or matrices)

..$A0

intercepts

..$sigma

variances of innovations

..$par.emis

parameters of non homogeneous emissions

..$par.trans

parameters of non homogeneous transitions

label

model's label

Details

The default implemented link function for non homogneneous intercept is the linear function $$A0_t^{(x)} = \theta_{A0}^{(x)} Z(t)$$ \(\theta_{A0}^{(x)}\) denotes a line vector here. Other link functions can be defined using nh.emissions (see above).

The default implemented link function for non homogneneous transitions is the Gauss function. Transition from \(i\) to \(j\) is defined as follows.

$$f(Z,\theta_Q,Q;i,j) = Q_{ij} \exp\left(-\frac{1}{2}\frac{(Z-\theta_Q^{(j)}(1))^2}{\theta_Q^{(j)}(2)}\right)$$ then \(f\) is normalized in order to define a stochastic matrix.

When, only two regimes are considered, the logistic link can be used. Probability of staying in state \(i\) is defined as follows $$f(Z,\theta_Q,Q;i,i) = \epsilon+(-2-\epsilon)/(1+\exp(\theta_Q^{(i)}(1)+\theta_Q^{(i)}[2:(d_Z+1)] Z)) $$ $$f(Z,\theta_Q,Q;i,j) = 1-f(Z,\theta_Q,Q;i,i)$$ with \(Z\) the covariate and eqnd_Z its dimension (number of covariates)

References

Ailliot, Monbet

See Also

fit.MSAR

Examples

Run this code
# NOT RUN {
data(meteo.data)
data = array(meteo.data$temperature,c(31,41,1)) 
k = 40
T = dim(data)[1]
N.samples = dim(data)[2]
d = dim(data)[3]

# Fit Homogeneous MS-AR models
M = 2
order = 2
theta.init = init.theta.MSAR(data,M=M,order=order,label="HH") 
mod.hh = fit.MSAR(data,theta.init,verbose=TRUE,MaxIter=10)
regimes.plot.MSAR(mod.hh,data,ylab="temperatures") 

## Not run
# Fit Non Homogeneous MS-AR models
#theta.init = init.theta.MSAR(data,M=M,order=order,label="NH",nh.transitions="gauss")
#attributes(theta.init)
#mod.nh = fit.MSAR(array(data[2:T,,],c(T-1,N.samples,1)),theta.init,verbose=TRUE,MaxIter=50,
#covar.trans=array(data[1:(T-1),,],c(T-1,N.samples,1)))
#regimes.plot.MSAR(mod.nh,data,ex=40,ylab="temperature (deg. C)")

## Not run
# Fit Non Homogeneous MS-AR models to lynx data
#data(lynx)
#data = array(lynx,c(length(lynx),1,1))
#theta.init = init.theta.MSAR(data,M=2,order=2,label="NH",nh.transitions="logistic")
#attributes(theta.init)
#mod.lynx = fit.MSAR(array(data[2:T,,],c(T-1,1,1)),theta.init,verbose=TRUE,MaxIter=200,
#covar.trans=array(data[1:(T-1),,],c(T-1,1,1)))
#regimes.plot.MSAR(mod.lynx,data,ylab="Captures number")
# }

Run the code above in your browser using DataLab